import { createApp } from 'vue'
import App from './App.vue'

// 引入自定义主题包
// import '@arco-themes/vue-heking-front/index.less'

import { setMixins } from '@components/index'

// 注册图标
import ArcoVueIcon from '@arco-design/web-vue/es/icon';

// 注册路由
import router from './router'

// 引入全局定义message
import MessageBox from '@/hooks/utils/message'
const message = new MessageBox()

// 注册pinia stroe
import { createPinia } from 'pinia'
import piniaPluginpersistedstate from 'pinia-plugin-persistedstate'
const pinia = createPinia()
pinia.use(piniaPluginpersistedstate)

// 获取状态
import { useUserMenuStore } from '@hook/store'

// 全局注册HTTP 请求方法
import HTTP from "@hook/httpServer/requst";
import server from "@hook/httpServer/httpServer";

// 引入字体样式
import '@assets/fonts/font.css'

// 全局样式配置
import './base.less'
import './main.less'


console.time('加载全局组件')
// 注册app ,同时挂载自定义指令集
const APP = setMixins(createApp(App))
console.timeEnd('加载全局组件')

APP.use(pinia)

// 挂载全局路由
window.$router = router

//处理路由 ， 防止刷新时动态路由消失， 需要在注册pinia之后 ， 注册router之前执行
const store = useUserMenuStore()

if(store.menu){
    store.setMenu(store.menu)
}

// 挂载全局api请求
window.$HTTP = HTTP
window.$Server = server

// 消息
window.$message = message

// 挂载全局环境变量
window.processEnv = import.meta.env

APP.use(router)
    .use(ArcoVueIcon)
    .mount('#app')
